home *** CD-ROM | disk | FTP | other *** search
- Path: news.sprintlink.net!datalytics!usenet
- From: Rob Stewart <stew@datalytics.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Coding Standards
- Date: Wed, 27 Mar 1996 16:53:52 -0500
- Organization: Datalytics, Inc
- Message-ID: <3159B8F0.22C6@datalytics.com>
- References: <4hj8ek$elu@sam.inforamp.net> <4hktar$5o2@galaxy.ucr.edu> <4io1a4$n9v@sam.inforamp.net> <4j8sdf$575@slbh00.bln.sel.alcatel.de>
- NNTP-Posting-Host: 204.62.224.71
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (WinNT; I)
-
- Marc Furguson wrote:
- >
- > Randy Charles Morin (rmorin@inforamp.net) wrote:
- > : In article <CBARBER.96Mar18104644@figaro.bbn.com>,
- > : cbarber@bbn.com (Christopher Barber) wrote:
- > --- snip ---
- > : > Randy> -a class which can be instantiated with a "new" must have a
- > : > Randy> copy constructor, a destructor and an assignment operator
- > : > Randy> definition. Most compilers (if not all) supply default copy
- > : > Randy> construtors. Unless you think your class may have copy behavior
- > : > Randy> problems, then writing copy constructors is redundant. When you
- > : > Randy> have 100+ classes to write and where the average copy
- > : > Randy> constructor has 50 lines, you would need 100 hours to write the
- > : > Randy> additional robustness (or cumbersomeness).
- > : >Aren't you getting a bit extreme here? I have written hundreds of
- > : >copy constructors and only a handful came even close to 50 lines long.
- > : >Yes, the compiler will generate a copy constructor for you, but it
- > : >has the wrong behavior in many cases.
- >
- > : Where am I being a little extreme? We do have 100+ classes, I have already
- > : identified about 100. I calculated the average amount of lines per copy
- > : constructor in another project and it came out just below 50. The average
- > : programmer on that project wrote less than 50 lines an hour. That's 100
- > : hours. It's math.
- > --- snip ---
- > : Agrivar
- >
-
- I can locate 100+ classes in my work and that of my coworkers.
- I don't think any of them have 50 line copy ctors. My questions
- are whether there are other functions (members or not) that
- would offload some of the behavior or whether the classes have
- too many dms. Most copy ctors do about what a normal ctor
- does--they must initialize or assign to the same dms--with some
- additional logic in place to handle reference counting or
- resource duplication.
-
- How is your copy ctors come to be so long?
-
- > Seems reasonable to me. It's not just a case of typing in copy constructors,
- > destructors etc. If the compiler does it just fine then let it. If you need
- > something else then code it, test it and document it. Now,
-
- That's the right attitude. Write the rule to encompass the
- circumstances under which you must provide your own copy ctor.
- Then, those understanding the rule will write a copy ctor when
- needed and can allow the compiler to do it when that is
- appropriate.
-
- >maybe I'm just
- > slow but I take a *lot* longer to test and document my software than I
- > take to write it, so I'd rather not write it in the first place if I
- > don't have to! On the other hand if your code is completely self-
- > documenting and is *always* faultless then just keep bashing away!
-
- --
- Robert Stewart | My opinions are usually my own.
- Datalytics, Inc. | stew@datalytics.com
-